package com.zb.manager.controller;

import com.zb.model.SysDes;
import com.zb.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

/**  
* <p>Title: CategoryController</p>  
* <p>Description: 管理部分的分类管理，实现分类的增删改查</p>
*/
@Controller
@RequestMapping("/notice")
public class NoticeController {

	@Autowired
	private NoticeService cs;
	
	/**
	 * SELECT NOTICE LIST
	 * @param session
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("/selectNotice")
	public String selectNotice(HttpSession session)throws Exception{
		List<SysDes> noticeList=cs.selectCate();
		session.setAttribute("noticeList", noticeList);
		return "admin/noticelist";
	}
	
	
	/**
	 * DELETE NOTICE
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("/delnoticebyid")
	public String deleteNotice(HttpServletRequest request)throws Exception{
		SysDes cate=new SysDes();
		String cateid = request.getParameter("noticeid");
		System.out.println("THE DELETING NOTICE IS "+cateid);
		cs.deleteCate(cateid);
		return "admin/noticelist";
	}
	
}
